package no.ntnu.fp.model;

import java.sql.ResultSet;
import java.util.ArrayList;

import no.ntnu.fp.storage.DBConnection;

public class Room extends ActiveRecord {
	private String name;
	private int capacity;
	
	public Room(String name, int capacity) {
		this.name = name;
		this.capacity = capacity;
	}
	
	public static String[] getAllRoomsLargerThan(int capacity) {
		DBConnection db = new DBConnection();
		
		String query = String.format("select navn from Moterom " +
				"where Storrelse >=" + capacity);
		ResultSet rs = db.makeSingleQuery(query);
		ArrayList<String> rooms = new ArrayList<String>();
		
		while (next(rs)) {
			String name = getString(rs, "navn");
			rooms.add(name);
		}
		
		closeDBConnection(db);
		
		String[] roomsArray = new String [rooms.size()];
		int i = 0;
		for (String room : rooms) {
			roomsArray[i] = room;
			i++;
		}
		return roomsArray;
	}

	@Override
	public void save() {
		System.out.println(name + capacity);
	}

	@Override
	public void edit(int index) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete() {
		// TODO Auto-generated method stub
		
	}
	
	

}
